package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.HeartMark;
import com.czh.springboot04.mapper.HeartMarkMapper;
import com.czh.springboot04.service.HeartMarkService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HeartMarkServiceImpl implements HeartMarkService {
    @Autowired
    private HeartMarkMapper heartMarkMapper;
    @Override
    public int addHeartMark(HeartMark heartMark) {
        return heartMarkMapper.addHeartMark(heartMark);
    }

    @Override
    public int deleteHeartMark(int id) {
        return heartMarkMapper.deleteHeartMark(id);
    }

    @Override
    public int updateHeartMark(HeartMark heartMark) {
        return heartMarkMapper.updateHeartMark(heartMark);
    }

    @Override
    public PageInfo<HeartMark> findAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<HeartMark> heartMarks=heartMarkMapper.findAll();
        PageInfo<HeartMark> pageInfo=new PageInfo<>(heartMarks);
        return pageInfo;
    }

    @Override
    public HeartMark findById(int id) {
        return heartMarkMapper.findById(id);
    }
}
